package com.mmall.concurrency.publishDemo;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * 定义一个数组，发布get方法，其他示例线程修改数组
 */
@Slf4j
public class UnSafePub {

    private String[] states = {"a","b","c","d"};

    // 发布出去一个
    public String[] getStates(){
        return states;
    }

    public static void main(String[] args){
        UnSafePub unSafePub = new UnSafePub();
        // log.info("init array: {}", unSafePub.getStates());
        log.info("Init array is: {}", Arrays.toString(unSafePub.getStates()));

        unSafePub.getStates()[0] = "FUCK!";
        log.info("After modify.the  array is: {}", Arrays.toString(unSafePub.getStates()));
    }

}
